package com.kinyx.framework.db.sentence.res;

import org.junit.Test;

import com.kinyx.framework.db.sentence.CompareType;
import com.kinyx.test.entities.impl.DemoEntityR;

public class Condition_Tester_Complex extends Condition_SUPER {

	@Test
	public void test1() {
		final String sentence = "(ID = ?)";
		final String str = "SQL: [" + sentence + "], params: [foo]";
		this.test(//
				Condition.of(//
						Condition.eq(DemoEntityR.id, "foo")//
				)//
				, sentence, str);
	}

	@Test
	public void test2AND() {
		final String sentence = "(ID = ? AND ID = ?)";
		final String str = "SQL: [" + sentence + "], params: [foo, bar]";
		this.test(//
				Condition.of(//
						Condition.eq(DemoEntityR.id, "foo")//
								.and(DemoEntityR.id, CompareType.EQ, "bar")//
				)//
				, sentence, str);
	}

	@Test
	public void test2OR() {
		final String sentence = "(ID = ? OR ID = ?)";
		final String str = "SQL: [" + sentence + "], params: [foo, bar]";
		this.test(//
				Condition.of(//
						Condition.eq(DemoEntityR.id, "foo")//
								.or(DemoEntityR.id, CompareType.EQ, "bar")//
				)//
				, sentence, str);
	}

}
